package hotel.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.springframework.format.annotation.DateTimeFormat;

/**
 * 酒店房间预订表，即订单
 * @author 15级信管四班第六小组
 */
@Entity
@Table
public class Reserve {

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private int reserveid;//主键
	
	@Column(nullable=false)
	private String userName;//预订人姓名
	
//	@Column(nullable=false)
//	private String id_number;//证件号码
	
	@Column(nullable=false)
	private String tele;//联系电话
	
	@JoinColumn
	@ManyToOne(fetch=FetchType.EAGER)
	private Category category;//预订商品
	
	@Column(nullable=false,columnDefinition="INT Default 1")
	private int amount;//预定数量，默认1
	
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Temporal(value=TemporalType.TIMESTAMP)
	private Date start_time;//预计入住时间
	
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Temporal(value=TemporalType.TIMESTAMP)
	private Date end_time;//预计退房时间
	
	@Column(nullable=false,columnDefinition="INT Default 1")
	private int days;//预计入住天数，系统根据入离时间自动计算
	
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Temporal(value=TemporalType.TIMESTAMP)
	@Column(nullable=false,columnDefinition="TIMESTAMP Default CURRENT_TIMESTAMP")
	private Date reserveTime;//下单时间，默认当前时间
	
	@Column(nullable=false)
	private String state;//订单状态:"取消","完成","已预订"

	@JoinColumn
	@OneToOne(fetch=FetchType.EAGER)
	private User operateUser;
	
	public int getReserveid() {
		return reserveid;
	}

	public void setReserveid(int reserveid) {
		this.reserveid = reserveid;
	}

	public User getOperateUser() {
		return operateUser;
	}

	public void setOperateUser(User operateUser) {
		this.operateUser = operateUser;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

//	public String getId_number() {
//		return id_number;
//	}
//
//	public void setId_number(String id_number) {
//		this.id_number = id_number;
//	}

	public String getTele() {
		return tele;
	}

	public void setTele(String tele) {
		this.tele = tele;
	}

	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	public int getAmount() {
		return amount;
	}

	public void setAmount(int amount) {
		this.amount = amount;
	}

	public Date getStart_time() {
		return start_time;
	}

	public void setStart_time(Date start_time) {
		this.start_time = start_time;
	}

	public Date getEnd_time() {
		return end_time;
	}

	public void setEnd_time(Date end_time) {
		this.end_time = end_time;
	}

	public int getDays() {
		return days;
	}

	public void setDays(int days) {
		this.days = days;
	}

	public Date getReserveTime() {
		return reserveTime;
	}

	public void setReserveTime(Date reserveTime) {
		this.reserveTime = reserveTime;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

}
